<template>
	<div class="container">
		<SearchForm
			@reset="reset"
			@search="search"
			ref="search"
			:queryParams="queryParams"
			labelWidth="100px">
			<el-form-item label="应收单号:">
				<el-input
					clearable
					v-model="queryParams.proceedsCode"
					placeholder="请输入应收单号"></el-input>
			</el-form-item>
			<el-form-item label="车牌号:">
				<el-input
					clearable
					v-model="queryParams.carCode"
					placeholder="请输入车牌号"></el-input>
			</el-form-item>
			<el-form-item label="业务单号:">
				<el-input
					clearable
					v-model="queryParams.earnCode"
					placeholder="请输入业务单号"></el-input>
			</el-form-item>
			<el-form-item label="客户:">
				<el-input
					clearable
					v-model="queryParams.earnCustomerName"
					placeholder="请输入客户名称"></el-input>
			</el-form-item>
			<el-form-item label="所属月份:">
				<el-date-picker
					clearable
					v-model="queryParams.affiliationMonth"
					value-format="yyyy-MM"
					type="month"
					placeholder="请选择月份"></el-date-picker>
			</el-form-item>
			<el-form-item label="应收类型:">
				<el-select
					v-model="queryParams.proceedsType"
					placeholder="请选择应收类型"
					clearable
					filterable>
					<el-option
						v-for="item in financeProceedsTypeList"
						:key="item.value"
						:label="item.label"
						:value="item.value"></el-option>
				</el-select>
			</el-form-item>
		</SearchForm>

		<div class="search_condition">
			<div
				class="item"
				v-for="item in search_condition"
				:key="item.label"
				:class="[item.value === queryParams.queryType ? 'active' : '']"
				@click="selectCondition(item)">
				{{ item.label }}
			</div>
		</div>
		<div class="card-wrap card-padding">
			<div class="table-title-wrap justify-end">
				<el-button
					type=""
					icon="el-icon-upload2"
					size="mini"
					@click="exportFile"
					v-hasPermi="['finance:manage:collect:list:export']">
					导出
				</el-button>
				<el-button
					type="primary"
					@click="collect"
					size="mini"
					v-hasPermi="[
						'finance:manage:collect:list:oneclickpayment',
					]">
					一键收款
				</el-button>
				<el-button
					type="primary"
					@click="verification"
					size="mini"
					v-hasPermi="['finance:manage:collect:list:verification']">
					付款流水核销
				</el-button>
			</div>

			<div class="tableBox">
				<table-page
					:loading="loading"
					:dataList="dataList"
					:total="total"
					:page.sync="queryParams.pageNum"
					:limit.sync="queryParams.pageSize"
					:border="true"
					@sortChange="sortChange"
					:default-sort="{ prop: 'periodsNum', order: 'descending' }"
					@setSizeCurrent="getList">
					<!-- 操作插槽 -->
					<template slot="tableColAc">
						<el-table-column
							label="操作"
							align="center"
							width="120">
							<template slot-scope="scope">
								<div class="handle">
									<el-button
										size="mini"
										type="text"
										@click="
											_toPage({
												path: '/finance/collectDetail',
												name: 'CollectDetail',
												query: {
													id: scope.row.proceedsId,
												},
											})
										"
										v-hasPermi="[
											'finance:manage:collect:list:look',
										]">
										查看
									</el-button>
									<!-- <el-button
										size="mini"
										type="text"
										v-if="
											scope.row.ticketStatus == '0' &&
											isAfterToday(
												scope.row.repaymentTime,
											)
										"
										@click="invoice(scope)"
										v-hasPermi="[
											'finance:manage:collect:list:invoice',
										]">
										开票
									</el-button> -->
									<el-button
										v-if="scope.row.waitAmount > 0"
										size="mini"
										type="text"
										@click="
											_toPage({
												path: '/finance/collectSingle',
												name: 'CollectSingle',
												query: {
													proceedsId:
														scope.row.proceedsId,
												},
											})
										"
										v-hasPermi="[
											'finance:manage:collect:list:invoice',
										]">
										收款
									</el-button>
								</div>
							</template>
						</el-table-column>
						<el-table-column
							label="应收单号"
							align="center"
							prop="proceedsCode"
							width="190">
							<template slot-scope="scope">
								<span class="sign_normal">
									{{ scope.row.proceedsCode || '-' }}
								</span>
							</template>
						</el-table-column>
						<el-table-column
							label="客户"
							align="center"
							width="100px"
							show-overflow-tooltip>
							<template slot-scope="scope">
								{{ scope.row.earnCustomerName || '-' }}
							</template>
						</el-table-column>
						<el-table-column
							label="车牌号"
							align="center"
							show-overflow-tooltip
							min-width="100px">
							<template slot-scope="scope">
								<span class="sign_normal">
									{{ scope.row.carCode || '-' }}
								</span>
							</template>
						</el-table-column>
						<el-table-column
							label="业务单号"
							align="center"
							prop="earnCode"
							min-width="250px">
							<template slot-scope="scope">
								<!-- {{ scope.row.periodsNum }} -->
								<el-link
									type="primary"
									@click="toDetail(scope.row)">
									{{ scope.row.earnCode || '-' }}
								</el-link>
							</template>
						</el-table-column>
						<el-table-column
							label="应收类型"
							align="center"
							prop="proceedsTypeStr"
							show-overflow-tooltip />
						<el-table-column
							label="期数"
							align="center"
							prop="periodsNum"
							show-overflow-tooltip
							:sort-orders="['descending', 'ascending']"
							:sortable="true">
							<template slot-scope="scope">
								{{ scope.row.periodsNum || '-' }}
							</template>
						</el-table-column>

						<el-table-column
							label="应收金额"
							show-overflow-tooltip
							align="center"
							prop="receivableAmount">
							<template slot-scope="scope">
								{{
									format_thousand(scope.row.receivableAmount)
								}}
							</template>
						</el-table-column>
						<el-table-column
							label="已收金额"
							align="center"
							show-overflow-tooltip
							prop="receivedAmount">
							<template slot-scope="scope">
								{{ format_thousand(scope.row.receivedAmount) }}
							</template>
						</el-table-column>
						<el-table-column
							label="待收金额"
							align="center"
							prop="waitAmount"
							show-overflow-tooltip>
							<template slot-scope="scope">
								{{ format_thousand(scope.row.waitAmount) }}
							</template>
						</el-table-column>
						<el-table-column
							label="核销状态"
							align="center"
							show-overflow-tooltip>
							<template slot-scope="scope">
								<span
									:class="[
										scope.row.checkState == 3 ||
										scope.row.checkState == 4
											? 'state_red'
											: '',
									]">
									{{ scope.row.checkStateStr || '-' }}
								</span>
							</template>
						</el-table-column>
						<el-table-column
							label="业务类型"
							align="center"
							show-overflow-tooltip>
							<template slot-scope="scope">
								{{ scope.row.earnTypeStr || '-' }}
							</template>
						</el-table-column>
						<el-table-column
							label="车辆来源"
							align="center"
							show-overflow-tooltip>
							<template slot-scope="scope">
								{{ scope.row.carSource || '-' }}
							</template>
						</el-table-column>
						<el-table-column
							label="车辆所属公司"
							align="center"
							show-overflow-tooltip
							min-width="120px">
							<template slot-scope="scope">
								{{ scope.row.carAppertainCompany }}
							</template>
						</el-table-column>
						<el-table-column
							label="车辆运营公司"
							align="center"
							show-overflow-tooltip
							min-width="120px">
							<template slot-scope="scope">
								{{ scope.row.carRunCompany }}
							</template>
						</el-table-column>

						<el-table-column
							label="开票状态"
							align="center"
							show-overflow-tooltip>
							<template slot-scope="scope">
								<template
									v-if="
										scope.row.proceedsType !== '6' &&
										scope.row.proceedsType !== '7'
									">
									{{ scope.row.ticketStatusStr || '-' }}
								</template>
								<template v-else>-</template>
							</template>
						</el-table-column>
						<el-table-column
							label="NC推送记录"
							align="center"
							show-overflow-tooltip
							min-width="120px">
							<template slot-scope="scope">
								<div>
									{{ scope.row.pushNc }}
									<!-- <el-button -->
									<!-- v-if="scope.row.pushNc === '已推送'" -->
									<!-- size="mini" -->
									<!-- type="text" -->
									<!-- @click="history_NC(scope.row)"> -->
									<!-- 查看 -->
									<!-- </el-button> -->
									<!-- <div v-else>未推送</div> -->
								</div>
							</template>
						</el-table-column>
						<el-table-column
							label="支付方式"
							align="center"
							show-overflow-tooltip>
							<template slot-scope="scope">
								{{
									scope.row.paymentMethodStr ||
									'-' | hideOn6(scope.row)
								}}
							</template>
						</el-table-column>
						<el-table-column
							label="账单日"
							align="center"
							show-overflow-tooltip
							min-width="100px">
							<template slot-scope="scope">
								{{
									scope.row.accountantBillDate
										| formatTime(0)
										| hideOn6(scope.row)
								}}
							</template>
						</el-table-column>
						<el-table-column
							label="还款日/开票时间"
							align="center"
							show-overflow-tooltip
							min-width="150px">
							<template slot-scope="scope">
								{{
									scope.row.repaymentTime
										| formatTime(0)
										| hideOn6(scope.row)
								}}
							</template>
						</el-table-column>

						<el-table-column
							label="实收时间"
							align="center"
							show-overflow-tooltip
							min-width="100px">
							<template slot-scope="scope">
								{{ scope.row.paymentTime | formatTime(0) }}
							</template>
						</el-table-column>
						<el-table-column
							label="逾期天数"
							align="center"
							show-overflow-tooltip>
							<template slot-scope="scope">
								{{
									scope.row.overdueDay ||
									'-' | hideOn6(scope.row)
								}}
							</template>
						</el-table-column>
					</template>
				</table-page>
			</div>
		</div>
		<!-- 一键收款 -->
		<el-dialog :visible.sync="dialog.collect.show" width="600px">
			<template #title>
				<div class="dialog_title">
					<div class="main">一键收款</div>
					<div class="tip">
						注意事项：只能是同一客户、车辆、订单的账单才能被一键收款。
					</div>
				</div>
			</template>
			<div class="dialogContent">
				<el-form
					:model="dialog.collect.form"
					ref="form_collect"
					label-width="80px"
					:inline="false"
					size="normal"
					label-position="left">
					<el-form-item
						label="收款方式"
						prop="paymentMethod"
						:rules="dialog.collect.rules.paymentMethod">
						<el-radio-group
							v-model="dialog.collect.form.paymentMethod"
							@change="change_paymentMethod">
							<el-radio
								:label="item.value"
								v-for="item in dialog.collect
									.paymentMethodOptions"
								:key="item.value">
								{{ item.label }}
							</el-radio>
						</el-radio-group>
					</el-form-item>

					<el-form-item label="收款时间" class="writeBox">
						<el-date-picker
							v-model="dialog.collect.form.paymentTime"
							type="date"
							placeholder="选择日期"
							value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
					</el-form-item>

					<el-form-item
						label="核销方式"
						prop="checkType"
						v-if="dialog.collect.form.paymentMethod == 1"
						:rules="dialog.collect.rules.checkType">
						<el-radio-group v-model="dialog.collect.form.checkType">
							<el-radio
								:label="item.value"
								v-for="item in dialog.collect.checkTypeOptions">
								{{ item.label }}
							</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item
						label="收款金额"
						prop="currentAmount"
						class="writeBox"
						v-if="dialog.collect.form.paymentMethod == 1"
						:rules="dialog.collect.rules.currentAmount">
						<el-input-number
							v-model="dialog.collect.form.currentAmount"
							:controls="false"
							:min="0"></el-input-number>
					</el-form-item>
				</el-form>
			</div>

			<span slot="footer">
				<el-button @click="dialog.collect.show = false">取消</el-button>
				<el-button type="primary" @click="collect_sure">确定</el-button>
			</span>
		</el-dialog>

		<!-- NC推送记录 -->
		<el-dialog
			:visible.sync="dialog.NC.show"
			:title="dialog.NC.title"
			width="70%">
			<div>
				<table-page
					:loading="dialog.NC.loading"
					:dataList="dialog.NC.dataList"
					:total="dialog.NC.total"
					:page.sync="dialog.NC.queryParams.pageNum"
					:limit.sync="dialog.NC.queryParams.pageSize"
					:border="true"
					@setSizeCurrent="getList_NC">
					<!-- 操作插槽 -->
					<template slot="tableColAc">
						<el-table-column label="推送类型" align="center">
							<template slot-scope="scope">
								<div>
									{{ scope.row.id }}
								</div>
							</template>
						</el-table-column>
						<el-table-column label="推送时间" align="center">
							<template slot-scope="scope">
								<div>
									{{ scope.row.id }}
								</div>
							</template>
						</el-table-column>
						<el-table-column label="推送状态" align="center">
							<template slot-scope="scope">
								<div>
									{{ scope.row.id }}
								</div>
							</template>
						</el-table-column>
						<el-table-column label="失败原因" align="center">
							<template slot-scope="scope">
								<div>
									{{ scope.row.id }}
								</div>
							</template>
						</el-table-column>
					</template>
				</table-page>
			</div>
			<div slot="footer">
				<el-button @click="dialog.NC.show = false">关 闭</el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script>
	import Uploadui from '@/components/FileUpload/upload_ui.vue';
	import {
		List,
		BatchProceeds,
		ExportFile,
		ImportStencilBatchProceeds,
		OrderParam,
		OrderCar,
	} from '@/api/finance/manage/collect/api.js';
	import FormItems from '@/views/finance/manage/formItems/index.vue';
	import * as app from '@/api/app.js';
	export default {
		name: 'Collect',
		components: { Uploadui, FormItems },
		dicts: ['finance_proceeds_type'],
		data() {
			return {
				value: '',
				options: '',
				total: 0,
				loading: true,
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					proceedsCode: '',
					carCode: '',
					earnCode: '',
					earnCustomerName: '',
					affiliationMonth: '',
					proceedsType: '',
					queryType: '',
					periodsNumSort: 'ascending',
				},
				dataList: [],
				search_condition: [
					{
						label: '全部',
						value: '',
					},
					{
						label: '待收款',
						value: 1,
					},
					{
						label: '已收款',
						value: 2,
					},
					{
						label: '已逾期',
						value: 3,
					},
					{
						label: '已生效',
						value: 4,
					},
					{
						label: '待生效',
						value: 5,
					},
					{
						label: '未推送NC',
						value: 6,
					},
					{
						label: '未开票',
						value: 7,
					},
				],
				dicts: {
					proceedsTypeList: [
						{
							label: '押金',
							value: 0,
						},
						{
							label: '租金',
							value: 1,
						},
						{
							label: '首付款',
							value: 2,
						},
						{
							label: '尾款',
							value: 3,
						},
						{
							label: '处置款',
							value: 4,
						},
						{
							label: '滞纳金',
							value: 5,
						},
					],
				},
				dialog: {
					collect: {
						show: false,
						form: {
							paymentMethod: '',
							paymentTime: '',
							checkType: '',
							currentAmount: '',
							proceedsIds: [],
						},
						rules: {
							checkType: [
								{
									required: true,
									message: '请选择核销方式',
									trigger: 'change',
								},
							],
							paymentMethod: [
								{
									required: true,
									message: '请选择收款方式',
									trigger: 'change',
								},
							],
							currentAmount: [
								{
									required: true,
									message: '请输入当前金额',
									trigger: 'change',
								},
							],
						},
						checkTypeOptions: [
							{
								label: '依次',
								value: 0,
							},
							{
								label: '平均',
								value: 1,
							},
						],
						paymentMethodOptions: [
							{
								label: '全额收款',
								value: 0,
							},
							{
								label: '部分收款',
								value: 1,
							},
						],
					},
					verification: {
						show: false,
						queryParams: {
							url: '',
						},
						state: 'upload',
					},
					NC: {
						show: false,
						title: '',
						loading: false,
						total: 0,
						dataList: [],
						queryParams: {
							pageNum: 1,
							pageSize: 10,
						},
					},
				},
			};
		},
		mounted() {
			this.getList();
		},
		computed: {
			financeProceedsTypeList() {
				return this.dict?.type?.finance_proceeds_type ?? [];
			},
			templateFileUrl() {
				return `${app.templateUrl}collect`;
			},
		},
		filters: {
			hideOn6(val, row) {
				if (row.proceedsType == 6 || row.proceedsType == 7) {
					return '-';
				} else {
					return val;
				}
			},
		},
		methods: {
			sortChange({ column, prop, order }) {
				// if (prop == 'periodsNum') {
				// 	this.queryParams.periodsNumSort = order;
				// }
				// this.getList();
			},
			invoice(scope) {
				this._toPage({
					path: '/finance/invoice',
					name: 'Invoice',
					query: {
						params: this.Base64.encode(
							JSON.stringify({
								deptName: scope.row.carAppertainCompany,
								firmCode: scope.row.firmCode,
								invoiceAmount: scope.row.receivableAmount,
								proceedsId: scope.row.proceedsId,
								proceedsCode: scope.row.proceedsCode,
								customerName: scope.row.earnCustomerName,
								customerCode: scope.row.earnCustomerCode,
							}),
						),
					},
				});
			},
			getOrderParam(orderCode) {
				if (this.Empty(orderCode)) return Promise.reject();
				return new Promise((resolve, reject) => {
					OrderParam(orderCode).then(res => {
						if (res.code == 200 && this.notEmpty(res.data)) {
							resolve(res.data);
						} else {
							reject(res);
						}
					});
				});
			},
			getOrderCar(orderCarId) {
				if (this.Empty(orderCarId)) return Promise.reject();
				return new Promise((resolve, reject) => {
					OrderCar(orderCarId).then(res => {
						if (res.code == 200 && this.notEmpty(res.data)) {
							resolve(res.data);
						} else {
							reject(res);
						}
					});
				});
			},
			async toDetail(row) {
				try {
					let { proceedsType, earnCode, earnId } = row;
					if (this.Empty(proceedsType)) return;
					this.$modal.loading('正在跳转中，请稍后...');
					let route = {};
					switch (proceedsType?.toString()) {
						// 租金 子订单
						case '1':
							let data1 = await this.getOrderCar(earnId);
							if (this.notEmpty(data1)) {
								route = {
									name: 'SuborderDetail',
									query: {
										id: data1.orderCarId,
										orderCarCode: data1.orderCarCode,
										estimatedDeliveryTime:
											data1.estimatedDeliveryTime,
										orderId: data1.orderId,
									},
								};
							}
							break;
						// 首期租金 子订单
						case '2':
							let data2 = await this.getOrderCar(earnId);
							if (this.notEmpty(data2)) {
								route = {
									name: 'SuborderDetail',
									query: {
										id: data2.orderCarId,
										orderCarCode: data2.orderCarCode,
										estimatedDeliveryTime:
											data2.estimatedDeliveryTime,
										orderId: data2.orderId,
									},
								};
							}
							break;

						// 尾款 子订单
						case '3':
							let data3 = await this.getOrderCar(earnId);
							if (this.notEmpty(data3)) {
								route = {
									name: 'SuborderDetail',
									query: {
										id: data3.orderCarId,
										orderCarCode: data3.orderCarCode,
										estimatedDeliveryTime:
											data3.estimatedDeliveryTime,
										orderId: data3.orderId,
									},
								};
							}
							break;
						// 处置款
						case '4':
							var data = await this.getOrderCar(earnId);
							if (this.notEmpty(data)) {
								route = {
									name: 'SuborderDetail',
									query: {
										id: data.orderCarId,
										orderCarCode: data.orderCarCode,
										estimatedDeliveryTime:
											data.estimatedDeliveryTime,
										orderId: data.orderId,
									},
								};
							}
							break;
						// 违约金
						case '5':
							let data5 = await this.getOrderParam(earnCode);
							if (this.notEmpty(data5)) {
								route = {
									name: 'OrderDetails',
									query: {
										type: data5.carType,
										orderId: data5.orderId,
										calcSchemeId: data5.calcSchemeId,
									},
								};
							}
							break;
						// 合同保证金 主订单
						case '6':
							let data6 = await this.getOrderParam(earnCode);
							if (this.notEmpty(data6)) {
								route = {
									name: 'OrderDetails',
									query: {
										type: data6.carType,
										orderId: data6.orderId,
										calcSchemeId: data6.calcSchemeId,
									},
								};
							}
							break;
						// 违章保证金 主订单
						case '7':
							let data7 = await this.getOrderParam(earnCode);
							if (this.notEmpty(data7)) {
								route = {
									name: 'OrderDetails',
									query: {
										type: data7.carType,
										orderId: data7.orderId,
										calcSchemeId: data7.calcSchemeId,
									},
								};
							}
							break;

						// 违章费用
						case '8':
							var data = await this.getOrderCar(earnId);
							if (this.notEmpty(data)) {
								route = {
									name: 'SuborderDetail',
									query: {
										id: data.orderCarId,
										orderCarCode: data.orderCarCode,
										estimatedDeliveryTime:
											data.estimatedDeliveryTime,
										orderId: data.orderId,
									},
								};
							}
							break;
						// 滞纳金
						case '9':
							var data = await this.getOrderCar(earnId);
							if (this.notEmpty(data)) {
								route = {
									name: 'SuborderDetail',
									query: {
										id: data.orderCarId,
										orderCarCode: data.orderCarCode,
										estimatedDeliveryTime:
											data.estimatedDeliveryTime,
										orderId: data.orderId,
									},
								};
							}
							break;
						// 加速折旧费
						case '10':
							var data = await this.getOrderCar(earnId);
							if (this.notEmpty(data)) {
								route = {
									name: 'SuborderDetail',
									query: {
										id: data.orderCarId,
										orderCarCode: data.orderCarCode,
										estimatedDeliveryTime:
											data.estimatedDeliveryTime,
										orderId: data.orderId,
									},
								};
							}
							break;
						// 超里程费
						case '11':
							var data = await this.getOrderCar(earnId);
							if (this.notEmpty(data)) {
								route = {
									name: 'SuborderDetail',
									query: {
										id: data.orderCarId,
										orderCarCode: data.orderCarCode,
										estimatedDeliveryTime:
											data.estimatedDeliveryTime,
										orderId: data.orderId,
									},
								};
							}

							break;
						// 自定义扣款项
						case '12':
							var data = await this.getOrderCar(earnId);
							if (this.notEmpty(data)) {
								route = {
									name: 'SuborderDetail',
									query: {
										id: data.orderCarId,
										orderCarCode: data.orderCarCode,
										estimatedDeliveryTime:
											data.estimatedDeliveryTime,
										orderId: data.orderId,
									},
								};
							}
							break;
						// 客户理赔款
						case '13':
							var data = await this.getOrderCar(earnId);
							if (this.notEmpty(data)) {
								route = {
									name: 'SuborderDetail',
									query: {
										id: data.orderCarId,
										orderCarCode: data.orderCarCode,
										estimatedDeliveryTime:
											data.estimatedDeliveryTime,
										orderId: data.orderId,
									},
								};
							}
							break;

						// 处置违约金
						case '14':
							var data = await this.getOrderCar(earnId);
							if (this.notEmpty(data)) {
								route = {
									name: 'SuborderDetail',
									query: {
										id: data.orderCarId,
										orderCarCode: data.orderCarCode,
										estimatedDeliveryTime:
											data.estimatedDeliveryTime,
										orderId: data.orderId,
									},
								};
							}
							break;
					}
					this.$modal.closeLoading();
					if (this.notEmpty(route)) {
						this._toPage(route);
					}
				} catch (error) {
					this.$message.error('未查找到相关订单信息！');
					this.$modal.closeLoading();
				}
			},

			isAfterToday(time) {
				if (!time || !this.$dayjs(time).isValid()) return false;
				return this.$dayjs().isSameOrAfter(this.$dayjs(time));
			},
			toPage(route) {
				this.$router.push(route);
			},
			search() {
				this.queryParams.pageNum = 1;
				this.getList();
			},
			reset() {
				this.queryParams = {
					pageNum: 1,
					pageSize: 10,
					periodsNumSort: 'ascending',
					queryType: '',
				};
				this.getList();
			},
			getList() {
				this.loading = true;
				List(this.queryParams)
					.then(res => {
						if (res.code == 200) {
							this.dataList = res.rows;
							this.total = res.total;
						}
					})
					.catch(() => {})
					.finally(() => {
						this.loading = false;
					});
			},
			exportFile() {
				// let params = {
				//     proceedsIds: this.getProceedsIds()?.join(","),
				// };
				let params = this._.cloneDeep(this.queryParams);
				this.download(
					ExportFile,
					params,
					`应收账款_${new Date().getTime()}.xlsx`,
				);
			},
			change_paymentMethod() {
				if (this.dialog.collect.form.paymentMethod == 0) {
					this.dialog.collect.form.checkType = '';
					this.dialog.collect.form.currentAmount = '';
				}
			},
			// NC推送记录
			history_NC(row) {
				this.dialog.NC.show = true;
				this.dialog.NC.title = 'NC推送记录';
				this.getList_NC(row);
			},
			getList_NC(row) {
				this.dialog.NC.loading = true;
				let params = {};
				List(params)
					.then(res => {})
					.catch(err => {})
					.finally(() => {
						this.dialog.NC.dataList = [{}];
						this.dialog.NC.total = 0;
						this.dialog.NC.loading = false;
					});
			},
			selectCondition(data) {
				this.queryParams.queryType = data.value;
				this.search();
			},

			// 一键收款
			collect() {
				this.dialog.collect.show = true;
			},
			getProceedsIds() {
				let arr = [];
				this.dataList.map(item => {
					arr.push(item?.proceedsId?.toString());
				});
				return arr;
			},
			async collect_sure() {
				let pass = await this.$refs.form_collect.validate();
				if (!pass) return;

				this.dialog.collect.form.proceedsIds = this.getProceedsIds();
				// console.log(this.dialog.collect.form);
				// return;
				this.$modal.loading('正在保存...');
				BatchProceeds(this.dialog.collect.form)
					.then(res => {
						if (res.code == 200) {
							this.$message({
								message: res.msg || '提交成功',
								type: 'success',
							});
							this.dialog.collect.show = false;
							this.getList();
						} else {
							this.$message({
								message: res.msg || '提交失败',
								type: 'error',
							});
						}
					})
					.finally(res => {
						this.$modal.closeLoading();
					});
			},
			// 流水核销
			verification() {
				this._toPage({ name: 'OneClickVerification' });
				// this.$UploadDialog({
				// 	showtoastSureBtn: false,
				// 	showErrorFeedback: false,
				// 	uploadConfig: {
				// 		uploadFileUrl: `#${ImportStencilBatchProceeds}`,
				// 		limit: 1,
				// 		params: {},
				// 		fileType: ['xlsx'],
				// 		templateUrl: this.templateFileUrl,
				// 		templateName: `应收账款-导入模版_${new Date().getTime()}.xlsx`,
				// 	},
				// }).then(res => {
				// 	console.log(res);
				// });
			},
			verification_sure() {
				this.$refs.upload_ui.submit();
				this.verification_state('uploading');
			},
			// dialog关闭后触发
			verification_closed() {
				this.verification_init();
			},
			// 初始化数据
			verification_init() {
				this.dialog.verification.queryParams.url = '';
				this.verification_state('upload');
			},
			// 所有文件上传完毕后触发
			afterUpload() {
				this.verification_state('afterUpload');
			},
			// 修改上传状态，影响上传关闭按钮
			verification_state(state) {
				this.dialog.verification.state = state;
			},
		},
		activated() {
			this.getList();
		},
	};
</script>

<style scoped lang="scss">
	.container {
		box-sizing: border-box;
		margin: 15px;
	}

	.tableBox {
		margin-top: 10px;
		background-color: #fff;
	}
	.searchbtns {
		padding: 20px 15px;
		background-color: #fff;
		display: flex;
		justify-content: space-between;
	}
	.search_condition {
		margin-top: 15px;
		padding: 15px 20px 0;
		background-color: #fff;
		display: flex;
		gap: 10px;
		flex-wrap: wrap;
		.item {
			font-size: 14px;
			padding: 10px 15px;
			border: 1px solid #ccc;
			border-radius: 7px;
			cursor: pointer;
			background-color: #fff;
			min-width: 74px;
			text-align: center;
		}
		.active {
			border-color: #339dff;
			color: #339dff;
		}
	}
	.search_handle {
		margin-top: 15px;
	}
	.handle {
		display: flex;
		justify-content: space-around;
	}
	.dialog_title {
		.main {
			font-weight: 500;
			font-size: 16px;
			color: #333;
			padding-bottom: 5px;
		}
		.tip {
			color: #eb7785;
			font-size: 12px;
		}
	}
	.tips {
		margin: 15px;
		font-size: 12px;
		color: red;
		.tips_title {
			font-size: 14px;
		}
	}
	// ::v-deep div:empty::after {
	//     content: "-";
	// }

	.dialogContent {
		margin: 15px 20px;
	}
	::v-deep .el-input-number {
		width: 220px;
		input {
			width: 100%;
			text-align: left;
			padding: 0 15px !important;
		}
		.el-input-number__decrease {
			display: none;
		}
		.el-input-number__increase {
			display: none;
		}
	}
	.sign_normal {
		color: #1d4ed8;
	}
	.handle {
		display: flex;
		justify-content: space-around;
		::v-deep .el-button + .el-button {
			margin: 0;
		}
	}
</style>
